package demo_8_IO;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class bufferedinputsteam {
	public static void main(String[] args) {
		copyFile("d://wl_system.log", "d://wl_system1.log");
		
	}
	
	private static void copyFile(String src,String dec){
		 FileInputStream fis=null;
		 BufferedInputStream bis=null;
		 FileOutputStream fos=null;
		 BufferedOutputStream bos=null;
		 int temp=0;
		 try {
			fis=new FileInputStream(src);
			fos=new FileOutputStream(dec);
			bis=new BufferedInputStream(fis);
			bos=new BufferedOutputStream(fos);
			while ((temp=bis.read())!=-1) {
				bos.write(temp);
			}
		} catch (Exception e) {
			// TODO: handle exception
		}
		 finally{
			 try {
				bos.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			 try {
				bis.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			 try {
				fos.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			 try {
				fis.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			 
		 }
		 
		
	}
}
